c <- read_csv("https://byuistats.github.io/M335/data/sales.csv ")
## Parsed with column specification:
## cols(
## Name = col_character(),
## Type = col_character(),
## Time = col_datetime(format = ""),
## Amount = col_double()
## )
c$Time<-with_tz(c$Time,tz="MST")
c1 <- mutate(c, Time=ymd_hms(Time),Month=month(Time,label=TRUE),Weakday=wday(Time,label=T),hour=hour(Time))
c1
## # A tibble: 15,656 x 7
## Name Type Time Amount Month Weakday hour
## <chr> <chr> <dttm> <dbl> <ord> <ord> <int>
## 1 Tacontento Food(prepared) 2016-05-16 12:01:00 3 May Mon 12
## 2 Tacontento Food(prepared) 2016-05-16 12:01:00 1.5 May Mon 12
## 3 Tacontento Food(prepared) 2016-05-16 12:04:00 3 May Mon 12
## 4 Tacontento Food(prepared) 2016-05-16 12:04:00 3 May Mon 12
## 5 Tacontento Food(prepared) 2016-05-16 12:04:00 1.5 May Mon 12
## 6 Tacontento Food(prepared) 2016-05-16 12:04:00 1 May Mon 12
## 7 Tacontento Food(prepared) 2016-05-16 12:07:00 3 May Mon 12
## 8 Tacontento Food(prepared) 2016-05-16 12:07:00 3 May Mon 12
## 9 Tacontento Food(prepared) 2016-05-16 12:07:00 1.5 May Mon 12
## 10 Tacontento Food(prepared) 2016-05-16 12:07:00 3 May Mon 12
## # ... with 15,646 more rows
c2 <- filter(c1,Name!="Missing"&Month!="04"&Type!="")
c3<- c2 %>% group_by(Name, Type, hour, Weakday,Month) %>% summarise(Amount=sum(Amount))
## `summarise()` regrouping output by 'Name', 'Type', 'hour', 'Weakday' (override with `.groups` argument)
p<- ggplot(c3,aes(y=Amount,x=as.factor(Month),col=Name,group=hour))+facet_wrap(~Name)+geom_boxplot()+theme_bw()
ggplotly(p, tooltip=c("Weakday","Amount"))
## Warning: `group_by_()` is deprecated as of dplyr 0.7.0.
## Please use `group_by()` instead.
## See vignette('programming') for more help
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_warnings()` to see where this warning was generated.
p<- ggplot(c3,aes(y=Amount,x=as.factor(hour),col=Name,group=Weakday,size=hour))+facet_wrap(~Name+Month+Type)+geom_boxplot()+theme_bw()
ggplotly(p, tooltip=c("hour","Amount"))
p<- ggplot(c3,aes(y=Amount,x=as.factor(Weakday),col=Name,size=hour))+facet_wrap(~Name)+geom_boxplot(aes(hour))+theme_bw()
ggplotly(p, tooltip=c("hour","Amount"))
p<- ggplot(c3,aes(y=Amount,x=as.factor(Weakday),col=Name,size=hour))+facet_wrap(~Name)+geom_violin()+theme_bw()
ggplotly(p, tooltip=c("hour","Amount"))
Hours of Operation should be between 9 and 12 pm when the business type is Service. When the business type is Food, 11 am, 12pm ,and from 4pm to 7pm should are the best hours of operation.